#import "SEGReceiveprizeManager.h"

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif
#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif

static id _receivePrizeManager;
static dispatch_once_t onceToken;

@implementation SEGReceiveprizeManager
#pragma mark - SINGLE----BEGIN----
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _receivePrizeManager = [[self alloc] init];
    });
    return _receivePrizeManager;
}

+(void)destroyResource{
    onceToken = 0;
    _receivePrizeManager = nil;
}

#pragma mark - SINGLE----END----

#pragma mark - HTTP----BEGIN----

/// 领取奖品接口
/// @param recordId 记录ID
/// @param winnerDetail 中奖详情：JSON串{"addressee":"收件人","tel":"手机号","address":"地址"}
-(void)requestReceiveprizeWithRecordid:(NSString*)recordId winnerDetail:(NSString*)winnerDetail finished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:recordId forKey:@"recordId"];
    [params setValue:winnerDetail forKey:@"winnerDetail"];
    
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/cms-api/example/receivePrize",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        self.receivePrize = [SEGReceiveprizeModel yy_modelWithDictionary:result];
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}
#pragma mark - HTTP----END----

#pragma mark - GETTER----BEGIN----
-(SEGReceiveprizeModel *)receivePrize{
    if (!_receivePrize) {
        _receivePrize = [[SEGReceiveprizeModel alloc]init];
    }
    return _receivePrize;
}
#pragma mark - GETTER----END----
@end
